package homework2;

public class Business extends Thread{

    private boolean flag = false;
    public synchronized void mainMethod() {
        while (false == flag) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName() + i);
        }
        flag = false;
        notify();
    }
    public synchronized void subMethod() {
        while (true == flag) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.println(Thread.currentThread().getName() + i);
        }
        flag = true;
        notify();
    }
}
